<template>
  <a-spin :spinning="spinning" tip="素材同步中，请耐心等待...">
  <a-card :bordered="false">
    <h3>推送详情</h3>
    <a-form-model
      :labelCol="{ lg: { span: 6 }, sm: { span: 8 } }"
      :wrapperCol="{ lg: { span: 14 }, sm: { span: 16 } }"
    >
      <a-form-model-item label="投放小程序">
        {{filterBrand}}
      </a-form-model-item>
      <a-form-model-item label="消息类型">
        {{details.advicesName}}
      </a-form-model-item>
      <a-form-model-item label="消息内容">
        {{details.advicesContent}}
      </a-form-model-item>
      <a-form-model-item  label="发送方式">
        <span v-if="details.sendWay == 0">立即发送</span>
        <span v-if="details.sendWay == 1">定时发送</span>
      </a-form-model-item>
      <a-form-model-item v-if="details.sendObject == 0" label="推送对象">
        全部用户
      </a-form-model-item>
      <a-form-model-item v-if="details.sendObject == 1" label="推送对象">
        {{details.sendObjectIdentityList.map(e => e.identityName).join('、')}}
      </a-form-model-item>
      <a-form-model-item v-if="details.sendObject == 2" label="推送对象">
         <SendUser :isDetails="true" v-if="details.id" :id="details.id"></SendUser>
      </a-form-model-item>

      <a-form-model-item label="跳转方式">
        <span v-if="details.jumpWay == 0">小程序</span>
        <span v-if="details.jumpWay == 1">不跳转</span>
        <span v-if="details.jumpWay == 2">自定义链接</span>
        <span v-if="details.jumpWay == 3">视频号</span>
        <span v-if="details.jumpWay == 4">话题</span>
      </a-form-model-item>
      <a-form-model-item  v-if="details.jumpWay == 0" label="appid">
        {{details.appId}}
      </a-form-model-item>
      <a-form-model-item v-if="details.jumpWay !== ''  && details.jumpWay!=1 && details.jumpWay !=4" label="落地页">
       {{details.landingPage}}
      </a-form-model-item>
      <a-form-model-item label="话题" v-if="details.jumpWay == 4">
        {{details.topicName}}
      </a-form-model-item>
    </a-form-model>
  </a-card>
  </a-spin>
</template>
<script>
import { advicesDetail } from '@/api/micromall/communityMarketing'
 import { brandList } from '../../components/brandList.js'
 import SendUser from '../../components/SendUser'
  const columns = [
  {
    title: '序号',
    width: 1,
    align: 'center',
    scopedSlots: { customRender: 'index' }
  },
  {
    title: '发送对象',
    width: 4,
    align: 'center',
    dataIndex: 'mobile'
  }
]
  export default {
    components: {
      SendUser
    },
    data() {
      return {
        details: {},
        brandList,
        columns,
        pagination: {
          current: 1,
          pageSize: 10,
          total: 0,
          showTotal: total => `共有 ${total} 条数据`
        },
        sendUserList: [1,2,3,4],
        spinning: false
      }
    },
    created() {
      this.getDetails()
    },
    computed: {
      filterBrand() {
        const configIdList = this.details.configId ? String(this.details.configId).split(',') : []
        let brandNameList = []
        configIdList.forEach(e => {
          brandNameList = brandNameList.concat(this.brandList.filter(i => i.weid==e))
        })
        return brandNameList.map(e => e.name).join(',')
      }
    },
    mounted() {
    },
    beforeDestroy() {
    },
    methods: {
      // 获取详情
      getDetails() {
        const id = this.$route.params.id
        if (id == 'null') return
        const data = {
          id,
          current:1
        }
        advicesDetail(data).then(res => {
          if (res.code == 200) {
            this.details = res.data.records[0]
          } else {
            this.$message.error(res.msg || res.message)
          }
        })
      },

      
      //返回
      handleBack() {
        this.$router.go(-1)
      },

      filterOption(input, option) {
        return (
          option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
        )
      },
    }
  }
</script>
<style lang="less" scoped>
  .hidden-title /deep/ .ant-form-item-label > label {
    visibility: hidden;
  }
</style>
